package com.woniuxy.controller;

import com.woniuxy.commons.entity.User;
import com.woniuxy.commons.service.IDoctorService;
import com.woniuxy.commons.service.UserService;

import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.entity.RegisteredOrder;
import com.woniuxy.service.RegisteredOrderService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class RegisteredOrderController {
    @Resource
    IDoctorService iDoctorService;
    @Resource
    UserService userService;
    @Resource
    RegisteredOrderService registeredOrderService;
    @ApiOperation(value = "获取所有挂号数据")
    @GetMapping("/registeredorder/findAll/{currentPage}/{pageSize}")
    public ResponseResult findAll(@ApiParam(name = "currentPage", value="当前页码",required=true)@PathVariable int currentPage,
                                  @ApiParam(name = "pageSize", value="页面大小",required=true)@PathVariable int pageSize){

        return registeredOrderService.findAll(currentPage,pageSize);
    }
    @PostMapping("/registeredorder/search")
    public ResponseResult search(@RequestBody RegisteredOrder registeredOrder){

        return  registeredOrderService.search(registeredOrder);
    }
    @GetMapping("/registeredorder/findByStatus/{status}")
    public ResponseResult findByStatus(@ApiParam(name = "status", value="支付状态",required=true)@PathVariable int status){
        return registeredOrderService.findByStatus(status);
    }
    @GetMapping("/user/findByName/{name}")
    public ResponseResult<User> findByName(@PathVariable String name){
        return userService.findByName(name);
    };
    @GetMapping("/registeredorder/findByNo/{order_num}")
    public ResponseResult findByRecord(@PathVariable(value="order_num") String order_num) {
        return registeredOrderService.findByNo(order_num);
    }
    @GetMapping("/findDoctorByName/{name}")
    public ResponseResult findDoctorByName(@PathVariable(value = "name") String name){
        return iDoctorService.findDoctorByName(name);
    }
}
